/*********************************************************
          File Name:top_low_const.cpp
          Author: Abby Cin
          Mail: abbytsing@gmail.com
          Created Time: Tue 15 Sep 2015 09:29:54 AM CST
**********************************************************/

#include <iostream>
using namespace std;

int main()
{
        int a = 10, b = 20;
        int *m = &b;
        const int *p = &a;
        // `low-level` const
        // i.e, after being initialized we can't write
        // *p = 1       i.e, we can't change the value where it point to
        // but we can't change where it point to
        p = m;

        cout << *p << endl;

        int *const q = m;
        // `const` is `top-level` const
        // it means that the pointer itself is const we can't do this
        // q = m;       i.e, we can't change where it point to, but we can change
        // the value where it point to
        *q = 309;

        // combine the above 
        const int *const n = m;
        // after being initialized, we can't neither change the value where it point
        // to nor change where it point to
        // *n = 1;      (wrong)
        // n = &a       (wrong)

        cout << n << endl;
}
